package com.zhangbo.study.designpatternlearning.decorator;

/**
 * 装饰者模式
 */
public class DecoratorRun {

    public static void main(String[] args) {
        // 构建一个不被装饰的对象
        Beverage beverage = new Espresso();
        System.out.println(beverage.getDescription() + " $" + beverage.cost());

        // 构建一个被Mocha装饰的对象
        Beverage beverage2 = new Mocha(new Espresso());
        System.out.println(beverage2.getDescription() + " $" + beverage2.cost());

        // 构建一个被Mocha和Whip装饰的对象
        Beverage beverage3 = new Whip(beverage2);
        System.out.println(beverage3.getDescription() + " $" + beverage3.cost());
    }
}
